package com.cat.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.context.annotation.Bean;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

@Data
@Builder
@Schema(description = "系统用户表")
@AllArgsConstructor
@NoArgsConstructor
//@TableName(value = "employee",autoResultMap = true)
public class Employee implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "id")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @Schema(description = "用户名")
    private String username;

    @Schema(description = "真实姓名")
    @TableField("realname")
    private String realName;

    @Schema(description = "所在部门ID")
    private Integer departmentId;

    @Schema(description = "密码")
    @TableField(fill = FieldFill.INSERT,value = "pwd")
    private String password;

    @Schema(description = "手机号")
    private String phone;

    @Schema(description = "等级")
    private String roles;

    @Schema(description = "性别(0 未知 1 男 2 女)")
    @TableField("sex")
    private Integer gender;

    @Schema(description = "生日")
    private String birthday;

    @Schema(description = "头像地址")
    private String avatar;

    @Schema(description = "年龄")
    private Integer age;

    @Schema(description = "身份证")
    private String idCard;

    @Schema(description = "邮箱地址")
    private String email;

    @Schema(description = "账户状态 (如 0 冻结；1 正常。)")
    private Integer status;

    @Schema(description = "用户按钮权限")
//    @TableField(typeHandler = JacksonTypeHandler.class)
    private String buttons;

    @Schema(description = "最近一次登录时间")
    private LocalDateTime lastLoginTime;

    @TableField(fill = FieldFill.INSERT)
    @Schema(description = "创建时间")
    private LocalDateTime createTime;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @Schema(description = "更新时间")
    private LocalDateTime updateTime;

    @Schema(description = "是否删除")
    private String delFlag;

    @Schema(description = "密码错误次数")
    private Integer loginErrorCount;

    @TableField(fill = FieldFill.INSERT)
    @Schema(description = "创建人")
    private Long createBy;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @Schema(description = "更新人")
    private Long updateBy;

}
